import org.jbox2d.common.Vec2;

public class SimulatedInput {
    /** Mouse position in world coordinates (not screen!) */
    private float mouseX,mouseY;
    private boolean mouseDown, pMouseDown;
    private boolean up, down, left, right;

    public SimulatedInput() {
        mouseX = mouseY = 0f;
        mouseDown = pMouseDown = false;
        up = down = left = right = false;
    }

    public void storeLast() {
        pMouseDown = mouseDown;
    }

    public void mouseDown() {
        mouseDown = true;
    }

    public boolean isMouseDown() {
        return mouseDown;
    }

    public void mouseUp() {
        mouseDown = false;
    }

    public float getMouseX() {
        return mouseX;
    }

    public float getMouseY() {
        return mouseY;
    }

    public Vec2 getMousePosition() {
        return new Vec2(mouseX, mouseY);
    }

    public void setMousePosition(Vec2 newPos) {
        mouseX = newPos.x;
        mouseY = newPos.y;
    }

    public boolean getMouseDown() {
        return mouseDown;
    }

    /** Has the mouse just been clicked? */
    public boolean isMousePressed() {
        if (mouseDown && (!pMouseDown)) return true;
        else return false;
    }

    /** Has the mouse just been released? */
    public boolean isMouseReleased() {
        if (pMouseDown && (!mouseDown)) return true;
        else return false;
    }

    public void setArrows(boolean u, boolean d, boolean l, boolean r) {
        up = u;
        down = d;
        left = l;
        right = r;
    }

    public boolean[] getArrows() {
        return new boolean[] {up, down, left, right};
    }
}
